import requests

from config import *

class PageApi():
    def __init__(self):
        self.banner_url = MAIN_URL + "/api/v1/banner/{}"
        self.theme_url = MAIN_URL + "/api/v1/theme?ids=1,2,3"
        self.recent_url = MAIN_URL + "/api/v1/product/recent"
    # 统一操作
    def get_resp(self, url):
        resp = requests.get(url)
        return resp
    # 首页轮播图
    def banner_response(self, ID):
        url = self.banner_url.format(ID)
        return self.get_resp(url)
    # 首页推荐信息
    def theme_response(self):
        url = self.theme_url
        return self.get_resp(url)
    # 首页当前流行商品
    def recent_response(self):
        url = self.recent_url
        return self.get_resp(url)
# 初始化
page_api = PageApi()